package com.klw.business.service.impl;

import java.math.BigDecimal;
import java.util.List;

import com.klw.business.domain.KlmBatchModel;
import com.klw.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.klw.business.mapper.KlwScoresMapper;
import com.klw.business.domain.KlwScores;
import com.klw.business.service.IKlwScoresService;

/**
 * 学生成绩Service业务层处理
 * 
 * @author klw
 * @date 2025-08-24
 */
@Service
public class KlwScoresServiceImpl implements IKlwScoresService 
{
    @Autowired
    private KlwScoresMapper klwScoresMapper;

    /**
     * 查询学生成绩
     * 
     * @param scoreId 学生成绩主键
     * @return 学生成绩
     */
    @Override
    public KlwScores selectKlwScoresByScoreId(Long scoreId)
    {
        return klwScoresMapper.selectKlwScoresByScoreId(scoreId);
    }

    /**
     * 查询学生成绩列表
     * 
     * @param klwScores 学生成绩
     * @return 学生成绩
     */
    @Override
    public List<KlwScores> selectKlwScoresList(KlwScores klwScores)
    {
        return klwScoresMapper.selectKlwScoresList(klwScores);
    }

    /**
     * 新增学生成绩
     * 
     * @param klwScores 学生成绩
     * @return 结果
     */
    @Override
    public int insertKlwScores(KlwScores klwScores)
    {
        klwScores.setCreateTime(DateUtils.getNowDate());
        return klwScoresMapper.insertKlwScores(klwScores);
    }

    /**
     * 修改学生成绩
     * 
     * @param klwScores 学生成绩
     * @return 结果
     */
    @Override
    public int updateKlwScores(KlwScores klwScores)
    {
        klwScores.setUpdateTime(DateUtils.getNowDate());
        return klwScoresMapper.updateKlwScores(klwScores);
    }

    /**
     * 批量删除学生成绩
     * 
     * @param scoreIds 需要删除的学生成绩主键
     * @return 结果
     */
    @Override
    public int deleteKlwScoresByScoreIds(Long[] scoreIds)
    {
        return klwScoresMapper.deleteKlwScoresByScoreIds(scoreIds);
    }

    /**
     * 删除学生成绩信息
     * 
     * @param scoreId 学生成绩主键
     * @return 结果
     */
    @Override
    public int deleteKlwScoresByScoreId(Long scoreId)
    {
        return klwScoresMapper.deleteKlwScoresByScoreId(scoreId);
    }

    /**
     * 获取学生指定学期的平均成绩
     * @param klmBatchModel
     * @return
     */
    @Override
    public BigDecimal selectAvgScoreByParam(KlmBatchModel klmBatchModel) {
        return klwScoresMapper.selectAvgScoreByParam(klmBatchModel);
    }

    /**
     * 获取学生指定学期挂科门数
     * @param klmBatchModel
     * @return
     */
    @Override
    public Long selectFailCountByParam(KlmBatchModel klmBatchModel) {
        return klwScoresMapper.selectFailCountByParam(klmBatchModel);
    }
}
